﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Models;
using Controller;
using System.Collections.Generic;

namespace UnitTest
{
    [TestClass]
    public class TestRoomTypeController
    {
        RoomTypeController roomTypeController = new RoomTypeController();
       
        [TestMethod]
        public void TestMethod1()
        {
            TblRoomType objRoomType = new TblRoomType();
            objRoomType.TypeName = "Miêu tả";
            objRoomType.Description = "Mô tả của super Luxury";
            objRoomType.TotalRoom = 10;
            objRoomType.TotalPeople = 2;
            objRoomType.DefaultPrice = 350000;

          
            roomTypeController.objRoomType = objRoomType;
            roomTypeController.AddData();
        }

        [TestMethod]
        public void TestGetAllDataRoomType()
        {
            List<TblRoomType> list = roomTypeController.GetAllData();
            foreach (TblRoomType item in list)
            {
                Console.WriteLine(item.TblRooms.ToString());
            }
        }

        [TestMethod]
        public void TestFindRoomTypeByKey()
        {
            TblRoomType obj = new TblRoomType();
            obj = roomTypeController.GetDataByRoomTypeID(1);
            Console.WriteLine(obj.TypeName.ToString());
        }

        [TestMethod]
        public void TestDeleteDataByKey()
        {
            TblRoomType obj = new TblRoomType();
            obj.RoomTypeID = 21;
            bool e = roomTypeController.DeleteData(obj.RoomTypeID);

            TblRoomType objNew = new TblRoomType();
            objNew = roomTypeController.GetDataByRoomTypeID(obj.RoomTypeID);
            if (objNew==null)
            {
                Console.WriteLine("Delete successful");
            }
            else
            {
                Console.WriteLine("Oop! Cannot Delete");
            }
        }

        [TestMethod]
        public void Updatedata()
        {
            roomTypeController.objRoomType = roomTypeController.GetDataByRoomTypeID(20);
            roomTypeController.objRoomType.TotalPeople = 100;

            roomTypeController.UpdateData();
        }
    }
}
